<template>
	<view>
		<view class="goods-item">
			<view class="goods-item-left">
				<radio :checked="item.goods_status" color="#c00000" v-if="showRadio" @click="radioClick" />
				<image :src="item.goods_small_logo" class="goods-pic"></image>
			</view>
			<view class="goods-item-right">
				<view class="goods-name">
					{{item.goods_name}}
				</view>
				<view class="goods-info">
					<view class="goods-price">
						￥{{item.goods_price+'.00'}}
					</view>
					<uni-number-box :min="1" :value="item.goods_count" v-if="showNum"
						@change="bindChange"></uni-number-box>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "my-goods",
		props: {
			item: {
				type: Object,
				default: {}
			},
			showRadio: {
				type: Boolean,
				default: false
			},
			showNum: {
				type: Boolean,
				default: false
			}
		},
		data() {
			return {

			};
		},
		methods: {
			radioClick() {
				this.$emit('radioChange', {
					goods_id: this.item.goods_id,
					goods_status: !this.item.goods_status
				})
			},
			bindChange(val) {
				this.$emit('numChange', {
					goods_id: this.item.goods_id,
					goods_count: +val
				})
			}
		}
	}
</script>

<style lang="scss">
	.goods-item {
		display: flex;
		padding: 10px 5px;
		border-bottom: 1px solid #f0f0f0;

		.goods-item-left {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-right: 5px;

			.goods-pic {
				width: 100px;
				height: 100px;
				display: block;
			}
		}

		.goods-item-right {
			flex: 1;
			display: flex;
			flex-direction: column;
			justify-content: space-around;

			.goods-name {
				font-size: 13px;
			}

			.goods-info {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.goods-price {
					font-size: 16px;
					color: #c00000;
				}
			}
		}
	}
</style>